package com.nf.xiaomi.service;

import com.alipay.api.AlipayApiException;
import com.nf.xiaomi.entity.CartItemEntity;
import com.nf.xiaomi.entity.OrderEntity;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

public interface PayService {
    String executePayment(HttpServletRequest request, HttpServletResponse response, Long account, Integer orderID, Integer state) throws AlipayApiException, IOException;

    default String getDetailNames(List<OrderEntity> orderEntityList){
        StringBuilder stringBuilder = new StringBuilder();
        for (int i = 0; i < orderEntityList.size(); i++) {
            stringBuilder.append(orderEntityList.get(i).getProductName());
            if (i != orderEntityList.size() - 1) {
                stringBuilder.append(", ");
            }
        }
        String names = stringBuilder.toString();
        return names;
    }
}
